'use strict';

module.exports = app => {
  const { router, controller: { comment }, middleware: { validator, checkPageTable, checkParams } } = app;

  const baseUrl = '/api/comment';
  router.get(baseUrl + '/my', checkPageTable(), comment.indexMy);
  router.get(baseUrl + '/online', checkPageTable(), comment.indexShops);
  router.get(baseUrl + '/examine', comment.indexExamine);
  router.get(baseUrl + '/user/:uid', checkParams('uid'), comment.indexByUser);
  router.patch(baseUrl + '/agree', validator('common.checkId'), comment.agree);
  router.patch(baseUrl + '/disagree', validator('common.checkId'), comment.disagree);
  router.get(baseUrl, checkPageTable(), comment.index);
  router.get(baseUrl + '/:id', checkParams(), comment.show);
  router.post(baseUrl, validator('comment.create'), comment.create);
  router.put(baseUrl + '/:id', checkParams(), validator('comment.update'), comment.update);
  router.delete(baseUrl + '/:id', checkParams(), comment.destroy);
};
